*12345678901234567890123456789012345678901234567890123456789012345678901234567890

capture log close
clear
clear matrix
set mem 500m
set more off

#delimit ;

log using "C:\Documents and Settings\James\Desktop\my dropbox\PTAs\BacciniData\baccini_election_timing.log", 
replace;

*	************************************************************************ *;
* 	File-Name: baccini_election_timing.do									 *;
*	Date:  1/03/10															 *;
*	Author: 	James Hollyer                                                *;
*	Purpose:   To examine how the timing of PTA formations compare with the  *;
*	electoral calandar.													 	 *;
*	Data Input: baccini_survival2.dta, election_dates.dta					 *;
*	************************************************************************ *;

use "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_survival2.dta";

sort ccode year; 

collapse (max) pta_sign polity2 (first) country, by(ccode year);

save "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_timing.dta",
replace;

clear;

use "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\election_dates.dta";

rename cow ccode;

sort ccode year;

*Collapse the data so that the observation is the country-year, rather than the;
*election-year.  We thus have indicators if there was an executive or legislative;
*election in a given country in a given year, and and indicator if there was a;
*electoral turnover in power in a given country in a given year.;

collapse (max) exelec legelec turnover (first) country, by(ccode year);

drop if year<1995;

merge 1:1 ccode year using "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_timing.dta";

*All of the cases in the Baccicni dataset are matched with those in the Kelly;
*data.  There are a number in the Kelly that don't have an anologue in the;
*Baccini data.  I drop these.;

drop if _merge~=3;
drop _merge;

*	************************************************************************ *;
*	Here I generate a variable that takes the value 1 if it is the year of   *;
*	or the year before an executive election, and I examine the distribution *;
*	of PTA signings when this variable takes the value 1 versus when it takes*;
*	the value zero.															 *;
*	************************************************************************ *;

gen election_period=1 if exelec==1|legelec==1;
replace election_period=1 if exelec[_n+1]==1 & ccode==ccode[_n+1];
replace election_period=1 if legelec[_n+1]==1 & ccode==ccode[_n+1];
replace election_period=0 if election_period==.;

ttest pta_sign if polity2>=5, by(election_period);

*It appears that democratic governments are much less likely to enter into a;
*PTA in an election year or in the year immediately preceeding an election.;
*This does not appear to support the theory - though there may be many;
*explanations for this tendency.;

